<?php

/**
* @desc Adapter. Define which type of object to work with. 
* 
* 
*/
class Kernel_Form_Order 
{
    
    /**
    * @desc Kernel_Form_Order_Simple or Kernel_Form_Order_Parent object. 
    * 
    * @param object
    */
    private $_object; 
    
    
    
    public function __construct($params = array()) 
    {
        $type = true === array_key_exists('parent', $params) ? 'parent' : 'simple';
        
        $this->_object = Kernel_Form_Order_Abstract::factory($type, $params);
    }
    
    public function addNode($position, $addit_values = array()) 
    {
        // varify for positive position otherwise it's senseless to proceed
        $position = (int)$position;
        if ($position < 1) { trigger_error('Position is not right', E_USER_ERROR); }
        
        return $this->_object->addNode($position, $addit_values);
    }
    
    public function moveNode($_id, $position) 
    {
        // varify for positive position otherwise it's senseless to proceed
        $position = (int)$position;
        if ($position < 1) { trigger_error('Position is not right', E_USER_ERROR); }
        
        $this->_object->moveNode($_id, $position);
    }
    
    public function deleteNode($_id) 
    {
        if ($_id < 1) { return 0; }
        
        return $this->_object->deleteNode($_id);
    }
    
}